package com.baselibrary.utils;

import com.baselibrary.MessageBus
import org.greenrobot.eventbus.EventBus

object EventBusUtils {
    @JvmStatic
    fun sendNotify(msgId: String) {
        val builder = MessageBus.Builder();
        val messageBus = builder.codeType(msgId).build();
        EventBus.getDefault().post(messageBus);
    }

    @JvmStatic
    fun sendJavaBean(msgId: String, param1: Any) {
        val builder = MessageBus.Builder()
        val messageBus = builder.codeType(msgId).param1(param1).build()
        EventBus.getDefault().post(messageBus)
    }

    @JvmStatic
    fun sendNotify1Value(msgId: String, param1: Any) {
        val builder = MessageBus.Builder();
        val messageBus = builder.codeType(msgId).param1(param1).build();
        EventBus.getDefault().post(messageBus);
    }

    @JvmStatic
    fun sendNotify2Value(msgId: String, param1: Any, param2: Any) {
        val builder = MessageBus.Builder();
        val messageBus = builder.codeType(msgId).param1(param1).param2(param2).build();
        EventBus.getDefault().post(messageBus);
    }


    @JvmStatic
    fun sendNotifyParams(msgId: String, param1: Any, param2: Any? = null, param3: Any? = null, param4: Any? = null, param5: Any? = null, param6: Any? = null, param7: Any? = null, param8: Any? = null) {
        val builder = MessageBus.Builder();
        val messageBus: MessageBus
        if (param2 == null) {
            messageBus = builder.codeType(msgId).param1(param1).build();
        } else {
            messageBus = builder.codeType(msgId).param1(param1).param2(param2).param3(param3).param4(param4).param5(param5).param6(param6).param7(param7).param8(param8).build();
        }
        EventBus.getDefault().post(messageBus);
    }

    @JvmStatic
    fun postSticky(bean: MessageBus) {
        EventBus.getDefault().postSticky(bean);
    }
    @JvmStatic
    fun sendNotify2Bean(bean: MessageBus) {
        EventBus.getDefault().post(bean);
    }

}
